import asyncio
import time

async def do_some_work(x):
    print('Waiting {}'.format(x))
    return 'Done after {}s'.format(x)

now = lambda: time.time()

if __name__ == '__main__':
    start = now()

    coroutine = do_some_work(2)
    loop = asyncio.get_event_loop()
    
    # 回调中我们使用了future对象的result方法,在这里，可以直接读取task的result方法
    task = asyncio.ensure_future(coroutine)
    loop.run_until_complete(task)
    print('Task ret: {}'.format(task.result()))

    print('TIME: {}'.format(now() - start))